#include <iostream>
#include <list>
#include <vector>
using namespace std;

struct LinkNode{
	int val;
	LinkNode* pnext;
	LinkNode(int nval):val(nval),pnext(nullptr){}
	~LinkNode(){}
};


LinkNode* Reverse(LinkNode* pHead)
{
	LinkNode* pPre = nullptr;
	LinkNode* pNex = nullptr;
	while(pHead != nullptr)
	{
		pNex = pHead->pnext;
		pHead->pnext = pPre;
		pPre = pHead;
		pHead = pNex;
	}
	return pPre;
}


vector<int> GetVal(LinkNode* pHead)
{
	vector<int> temp;
	while(pHead != nullptr){
		temp.push_back(pHead->val);
		pHead = pHead->pnext;
	}
	return temp;
}

int main()
{
	LinkNode a(1);
	LinkNode b(2);
	LinkNode c(3);
	a.pnext = &b;
	b.pnext = &c;
	c.pnext = nullptr;
	LinkNode* res = Reverse(&a);
	vector<int> s = {3,2,1};
	vector<int> bb = GetVal(res);
	if(s.size() != bb.size()){
		cout<<"Error Len "<<bb.size()<<endl;
		return 1;
	}
	for(int a = 0; a != s.size();++a){
		if(s[a] != bb[a]){
			cout<<"Error "<<a<<endl;
			return 1;
		}
	}
	cout<<"Success"<<endl;
}
